package laboesi;
import laboesi.td7.*;

public class PosMinB { 

    public static void initialiser (int [] tab){

	int i;

	for (i=0; i<tab.length; i++) {
	    tab[i]=999;
	}
    }

    public static void main ( String[] args ) { 

	int [] tabEnt = {1,4,6,8,1,4,1,3,5};
//		int [] tabEnt = {9,8,7,6,5,4,3,2,1};
//	int [] tabEnt = {1,2,3,4,5,6,7,8,9};
		//int [] tabEnt = {2,1,3,1,5,6,7,8,9};
//	int [] tabEnt = {9,8,7,6,5,4,3,1,2};
	int [] tabIndice;
	tabIndice = new int [tabEnt.length];

	int i, nbrDeMin, nbMin, nbNext;
	nbrDeMin = 1;
	initialiser(tabIndice);
	nbMin = tabEnt[0];
	tabIndice[0] = 0;
	TableauxInt.afficher(tabIndice);
	for ( i =1 ; i < tabEnt.length; i++) {

	    nbNext = tabEnt[i];

	    if ( nbMin > nbNext) {
		nbrDeMin = 0;
		initialiser(tabIndice);
		tabIndice[nbrDeMin] = i;
		nbMin = nbNext;
		nbrDeMin++;
		
	    }else {

		if ( nbMin == nbNext) {
		    tabIndice[nbrDeMin] = i;
			nbrDeMin++;	   
		}
	    }
	    

	}



	TableauxInt.afficher(tabEnt);
	TableauxInt.afficher(tabIndice);

    }

}
